# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=python2-markdown
_pkgname=Markdown
pkgver=3.1.1
pkgrel=6
pkgdesc='Python implementation of Markdown.'
url='https://pypi.org/project/Markdown/#files'
arch=('any')
license=('BSD')
depends=('python2')
makedepends=('python2-setuptools')
source=("https://files.pythonhosted.org/packages/source/${_pkgname::1}/$_pkgname/$_pkgname-$pkgver.tar.gz")
sha512sums=('78f089f2eef5c73d683ac96fd20c87145e243d12b0f230b9b0228b995035fbb084dde40be788679c63637f05956487ad520cc9dd61d133926bf13521aa600090')

build() {
  cd "$_pkgname-$pkgver"

  python2 setup.py build
}

prepare() {
  cd "$_pkgname-$pkgver"

  # weird, import error for 'pkg_resources'
  sed -i 's/^from pkg_resources.*$/import packaging.version/' \
    markdown/__init__.py
}

package() {
  cd "$_pkgname-$pkgver"

  python2 setup.py install --root="$pkgdir" --prefix=/usr -O1 --skip-build

  mv "$pkgdir/usr/bin/markdown_py" "$pkgdir/usr/bin/markdown_py2"
}

